<div id="main-content">
    <div id="main" class="main">
        <div class="user-hd">
            <h2>财务管理>>结算管理</h2>
        </div>
        <div class="clearfix searchspin">
            <dl>
                <dt>筛选条件:</dt>
                <dd>
                    <form method="get" action="{:U()}">
                        <span>结算状态:</span>
                        <select name="status" id="status" style="width:80px;">
                            <option value="0">全部</option>
                            <option value="done" <eq name="search.status" value="done">selected</eq>>已结算</option>
                            <option value="doing" <eq name="search.status" value="doing">selected</eq>>未结算</option>
                        </select>结算日期:
                        <input type="text" id="date_start" name="date_start" value="{:I('date_start')}" class="bg-input w88" <literal> onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'date_end\')||\'%y-%M-%d\'}'})" </literal> placeholder="开始日期" /> 至
                        <input type="text" id="date_end" name="date_end" value="{:I('date_end')}" class="bg-input w88 mr13" <literal> onfocus="WdatePicker({minDate:'#F{$dp.$D(\'date_start\')}', maxDate:'%y-%M-%d'})" </literal> placeholder="结束日期" />
                        <div class="typeahead-container">
                           <div class="typeahead-field">
                           <span class="typeahead-query">
                               <input name="name" class="bg-input w135" type="search" placeholder="请输入影院名称" autocomplete="off" value="{:I('request.name')}" >
                           </span>
                           </div>
                       </div>
                       <input type="button" value="清空" onclick="javascript:window.location.href='{:U('/Admin/Bill/index')}'" class="sblue-btn">
                       <button class="sblue-btn" onclick="this.form.submit();">搜索</button>
                        &nbsp
                        <button class="sblue-btn" id="baobiao" name="baobiao" value="1" onclick="this.form.submit();">下载报表</button>
                    </form>
                </dd>
            </dl>
        </div>
        <div class="clearfix searchspin">
            <span>结算总金额：</span><span>{$total_money}元</span>
            <span style="margin-left:5em;">结算次数：</span><span>{$total_count}次</span>
        </div>
        <!-- 列表 start -->
        <div class="spin-cont">
            <notempty name="data_list">
                <table>
                    <tr>
                        <th>结算单号</th>
                        <th>结算时间</th>
                        <th>结算影院</th>
                        <th>结算金额(元)</th>
                        <th>结算状态</th>
                        <th>操作</th>
                    </tr>
                    <volist name="data_list" id="vo">
                        <tr>
                            <td>{$vo.bill_sn}</td>
                            <td>{$vo.ctime|date='Y-m-d', ###}</td>
                            <td>{$vo.cinema_name}</td>
                            <td>{$vo.money_total}</td>
                            <td>
                                <eq name='vo.status' value='0'><span style="color:#dc5858;">未结算</span></eq>
                                <eq name='vo.status' value='1'><span style="color:green;">已结算</span></eq>
                            </td>
                            <td>
                                <eq name="vo.status" value='0'>
                                    <a href="javascript:;" class="finish" data-sn="{$vo.bill_sn}">确认结算</a>
                                    <span>|</span>
                                </eq>
                                <a href="{:U('/Admin/Bill/detail',array('bill_sn'=>$vo['bill_sn']))}" class="delfilebtn" >详情</a>
                            </td>
                        </tr>
                    </volist>
                </table>
                <div class="spin-upbox clearfix page txt-center">
                    {$pager}
                </div>
                <else />暂无记录...
            </notempty>
        </div>
    </div>
</div>

<script>
$('a.finish').click(function(){
	var bill_sn = $(this).attr('data-sn');
    swal({
        title: "确认结算账单: "+bill_sn+"？",
        text: "该操作无法撤回",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#0C7AB9",
        cancelButtonText: "取消",
        confirmButtonText: "确认",
        closeOnConfirm: false
        },
        function(){
            $.ajax({
            type:'post',
            dataType:'json',
            url:"{:U('/Admin/Bill/doFinish')}",
            data:{
            	bill_sn:bill_sn
            },
            success:function(data){
                if(data.error){
                    alertMessage(data.info);
                    return false;
                }else{
                    alertMessage(data.info,1,1);
                    delayGoToPage(window.location.href, 1000);
                }
            }
        });
        return true;
        }
    );
});
</script>